import React, { Component } from "react";
import { Card, Button, Form, Input, Select, Tree, Transfer, Modal } from "antd";
import ETable from "../../componets/Etable/index";
import axios from '../../axios/index'
// import menuConfig from '../../config/menuConfig'
import Utils from '../../utils/utils'

export default class Permission extends Component {
    constructor(props) {
        super(props)
    
        this.state = {
             list:[]
        }
    }
    componentWillMount(){
        this.requestList();   
    }

    requestList = ()=>{
        axios.ajax({
            url:'/role/list',
            data:{
                params:{}
            }
        }).then((res)=>{
            if(res.code == 0){
                let list  = res.result.item_list.map((item,i)=>{
                    item.key = i;
                    return item;
                })
                this.setState({
                    list
                })
            }
        })
    }
  render() {
    const columns = [
      {
        title: "角色ID",
        dataIndex: "id"
      },
      {
        title: "角色名称",
        dataIndex: "role_name"
      },
      {
        title: "创建时间",
        dataIndex: "create_time",
        render: Utils.formatTime
      },
      {
        title: "使用状态",
        dataIndex: "status",
        render(status) {
          if (status == 1) {
            return "启用";
          } else {
            return "停用";
          }
        }
      },
      {
        title: "授权时间",
        dataIndex: "authorize_time",
        render: Utils.formatTime
      },
      {
        title: "授权人",
        dataIndex: "authorize_user_name"
      }
    ];
    return (
      <div>
        <Card>
          <Button type="primary" onClick={this.handleRole}>
            创建角色
          </Button>
          <Button type="primary" onClick={this.handlePermission}>
            设置权限
          </Button>
          <Button type="primary" onClick={this.handleUserAuth}>
            用户授权
          </Button>
        </Card>
        <div className="content-wrap">
          <ETable columns={columns}  dataSource={this.state.list}/>
          
        </div>
      </div>
    );
  }
}
